const express = require('express')
const Mock = require('mockjs')

let app = express()

app.get('/getUser', (req, res) => {
  let data = Mock.mock({
    id: '@id',
    username: '@string("123456789abcdefghuritoplhb",8)',
  })
  res.json(data)
})

app.get('/content', (req, res) => {
  let resData = []
  for (var i = 1; i <= 100; i++) {
    let data = Mock.mock({
      id: '@id',
      title: '@ctitle',
      email: Mock.Random.email(),
      date: Mock.Random.datetime('yyyy-MM-dd'),
      username: '@cname',
      isDone: '@boolean',
      zipcode: /\d{6}/,
      ip: '@ip',
      province: '@province',
      address: '@city(true)',
      country: '@county(true)',
      color: Mock.Random.color(),
      city: '@city',
      content: '@cparagraph',
      create_date: '@datetime',
    })
    resData.push(data)
  }
  res.json(resData)
})

app.listen(4179, () => console.log('api server is running at port 4179'))
